package reduce.fz.com.reduce.adapter;

import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.File;
import java.util.List;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.util.PicassoUtil;

/**  111
 * Created by qingshengzheng on 15/8/9.
 */
public class WitnessAdapter extends BaseAdapter {
    private List<String> imageurls;
    private LayoutInflater layoutInflater;
    private Context context;

    public void addImageUrl(String localImageUrl)
    {
        imageurls.add(imageurls.size()-1,localImageUrl);
    }


    public WitnessAdapter(Context context, List<String> imageurls) {
        this.imageurls = imageurls;
        this.context = context;
        this.layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return imageurls.size();
    }

    @Override
    public Object getItem(int i) {
        return imageurls.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View view1 = layoutInflater.inflate(R.layout.witness_view, null);
        ImageView image = (ImageView) view1.findViewById(R.id.witness_image);
        PicassoUtil.laodUrl(context, imageurls.get(i), image);
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showPopupWidow();

            }
        });
        return view1;

    }

    public void showPopupWidow() {

        TextView select = null;
        TextView taskphone = null;

    }

    public void takePhone() {
        Uri imageUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "image.jpg"));

    }



}
